import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode;

import java.util.Arrays;
import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/2/28
 * Time: 20:17
 * Description:
 */
public class TestDemo {


    public static void main(String[] args) {
        String str1 = new String("1")+new String("1");
        str1.intern();
        String str2 = "11";
        System.out.println(str1 == str2);
    }


    public static void main10(String[] args) {
        String str1 = new String("hello");
        str1 = str1.intern();//手动入池
        String str2 = "hello";
        System.out.println(str1 == str2);
    }


    public static void main9(String[] args) {
        String str = "hello";
        String str2 = "hello";
        String s3 = new String("hello");
        String s4 = new String("hello");
        System.out.println(str == str2);

    }

    public static void main8(String[] args) {
        String str = "    ababc   abc  d        ";
        System.out.println(str);

        String str2 = str.trim();

        System.out.println(str2);

        /*String ret = str.substring(1,8);//[)
        System.out.println(ret);*/
    }

    public static void main7(String[] args) {
        String str = "name=zhangsan&age=18";
        String[] strings = str.split("&");//[name=zhangsan,age=18]
        for (String x : strings) {
            String[] strings1 = x.split("=");
            for(String x2 : strings1) {
                System.out.println(x2);
            }
        }
    }


    public static void main6(String[] args) {
        String str = "192&168=1&1";
        String[] strings = str.split("&|=");
        for (String s : strings) {
            System.out.println(s);
        }
    }


    public static void main5(String[] args) {
        String str = "ababcabcd";
       /* String ret = str.replace("ab","pp");
        System.out.println(ret);*/
       /* String ret  = str.replaceFirst("ab","uu");
        System.out.println(ret);*/

        String ret  = str.replaceAll("ab","uu");
        System.out.println(ret);
    }

    public static void main4(String[] args) {
        String str = "abaABabcdabcde";
        char[] ch = str.toCharArray();

        System.out.println(Arrays.toString(ch));


        System.out.println(str.indexOf("cd",3));
        System.out.println(str.lastIndexOf("abc"));

        System.out.println(str.toUpperCase());
        System.out.println(str.toLowerCase());

        String s = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(s);
    }

    public static void main3(String[] args) {
        String str = "abcdef";
        /*char ch = str.charAt(5);
        System.out.println(ch);*/
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            System.out.println(ch);
        }
    }

    public static void main2(String[] args) {
        String str = "Hello";
        System.out.println(str);

        String str2 = new String("hello");

        System.out.println(str == str2);

        System.out.println(str.equals(str2));
        System.out.println("gaobo".equals(str2));
        String str3 = null;
        System.out.println(str2.equals(str3));

        System.out.println(str.compareTo(str2));
        System.out.println(str.compareToIgnoreCase(str2));

    }
    public static void main1(String[] args) {
        String str = "hello";
        String str2 = new String("world");
        int[] array = {1,2,3};
        int[] array2 = new int[]{1,2,3};
    }
}
